//package com.boot.down.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.FilterType;
//import org.springframework.http.MediaType;
//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.servlet.HandlerAdapter;
//import org.springframework.web.servlet.ViewResolver;
//import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
//import org.springframework.web.servlet.view.InternalResourceViewResolver;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@Configuration
//@ComponentScan(value = "com.*", includeFilters = {@ComponentScan.Filter(
//        type = FilterType.ANNOTATION, value = Controller.class)})
////启动MVC
//@EnableWebMvc
//public class WebConfig {
//
//    @Bean(name = "internalResourceViewResolver")
//    public ViewResolver initViewResolver(){
//        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
//        viewResolver.setPrefix("view/");
//        viewResolver.setSuffix(".html");
//        return viewResolver;
//    }
//
//
//    /**
//     * 初始化适配器，同时转换http的json转换器
//     * @return
//     */
//
//    @Bean(name = "requestMappingHandlerAdapter")
//    public HandlerAdapter initRequestMappingHandlerAdapter(){
//
//        RequestMappingHandlerAdapter handlerAdapter = new RequestMappingHandlerAdapter();
//
//        MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
//
//        MediaType mediaType = MediaType.APPLICATION_JSON_UTF8;
//
//        List<MediaType> mediaTypeList = new ArrayList<>();
//
//        mediaTypeList.add(mediaType);
//        jsonConverter.setSupportedMediaTypes(mediaTypeList);
//
//        handlerAdapter.getMessageConverters().add(jsonConverter);
//
//        return handlerAdapter;
//
//    }
//
//}
